package cn.codeartist.springboot.component.dynamic;

import cn.codeartist.springboot.component.dynamic.aop.DynamicDataSourceAspect;
import cn.codeartist.springboot.component.dynamic.druid.DynamicDataSource;
import cn.codeartist.springboot.component.dynamic.interceptor.DynamicDataSourceInterceptor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 动态数据源组件
 *
 * @author 艾江南
 * @date 2019/4/23
 */
@Configuration
@ConditionalOnBean(DynamicDataSource.class)
public class DynamicAutoConfiguration {

    @Bean
    public DynamicDataSourceInterceptor dynamicDataSourceInterceptor() {
        return new DynamicDataSourceInterceptor();
    }

    @Bean
    public DynamicDataSourceAspect dynamicDataSourceAspect() {
        return new DynamicDataSourceAspect();
    }
}
